home *** CD-ROM | disk | FTP | other *** search
- /*==============================================================================
-
- FICHERO: VMS.C
-
- AUTOR: ANTONIO LADESA JURADO
-
- FECHA: 24/6/94
-
- DESCRIPCION:
-
- Fichero que contiene las estructuras, constantes, variables y funciones
- internas y externas para la gestión de memoria VMS.
-
- ==============================================================================*/
-
-
- /*---- MODULOS USADOS --------------------------------------------------------*/
-
- #include <string.h>
- #include <stdio.h>
- #include <io.h>
- #include <dir.h>
- #include <dos.h>
- #include <alloc.h>
- #include "vms.h"
-
- /*---- CODIFICACION DE LAS FUNCIONES OFRECIDAS -------------------------------*/
-
-
- /*---- FUNCION: extern VMSmemoria *VMSmemReservar(long int bytes) --------------
-
- Descripción:
-
- Esta función reserva un número de bytes de memoria VMS, es decir,
- crea un fichero de ese tamaño.
-
- Parámetros:
-
- long int bytes: número de bytes a reservar.
-
- Retorno:
-
- - Puntero a estructura del gestor VMS, que contiene los datos del fichero
- - Si hubo error, el puntero a fichero del gestor, es NULL.
-
- ---- CODIGO: -----------------------------------------------------------------*/
-
- extern VMSmemoria *VMSmemReservar(long int bytes)
- {
- /* gestor de memoria VMS */
- VMSmemoria VMSmem;
- /* manejador temporal */
- int manejador;
-
- /* inicializa gestor VMS */
- strcpy(VMSmem.fichero,"\\");
- VMSmem.gestor = NULL;
- /* crea fichero */
- manejador = creattemp(VMSmem.fichero, FA_ARCH);
- if(manejador != -1)
- close(manejador);
- else
- return(&VMSmem);
-
- /* abrir fichero */
- if((VMSmem.gestor = fopen(VMSmem.fichero,"wb+"))==NULL)
- return(&VMSmem);
-
- /* si no es lo suficientemente grande...*/
- fseek(VMSmem.gestor,0,SEEK_SET);
- while(bytes--)
- {
- if(fputc(0,VMSmem.gestor))
- {
- fclose(VMSmem.gestor);
- return(&VMSmem);
- }
- }
- /* devuelve gestor */
- return(&VMSmem);
- }
-
- /*---- FIN FUNCION -----------------------------------------------------------*/
-
-
- /*---- FUNCION: extern void VMSmemLiberar(VMSmemoria VMSmem) -------------------
-
- Descripción:
-
- Esta función libera memoria VMS reservada anteriormente.
- Es decir, borra el fichero.
-
- Parámetros:
-
- VMSmemoria VMSmem : gestor de memoria VMS a liberar
-
- ---- CODIGO: -----------------------------------------------------------------*/
-
- extern void VMSmemLiberar(VMSmemoria VMSmem)
- {
- /* si el fichero está abierto, cerrarlo y borrarlo */
- if(VMSmem.gestor!=NULL)
- {
- fclose(VMSmem.gestor);
- remove(VMSmem.fichero);
- }
- }
-
- /*---- FIN FUNCION -----------------------------------------------------------*/
-